<?php
// 本类由系统自动生成，仅供测试用途
class CommAction extends Action{
    public function _initialize(){
		$this->navInit();
     }



//初始化导航菜单 function navInit

	public function navInit(){
	

		$navigation = M("navigation");
		$nav_arr = $navigation->where("up_navi = 0")->order("orders asc")->findall();
		
		$sub_nav_arr = "";
		foreach($nav_arr as  $nav){
			
			//$nav_id_list[]= $nav['id'];
			$sub_nav_arr[$nav['id']] = $navigation->where("up_navi =".$nav['id'])->order("orders asc")->findall();

		}

		//dump($sub_nav_arr);
			
		$nav_str = "";
		$nav_choosed = "";
		
		foreach($nav_arr as $nav_one){

			
			$sub_nav_str = "";
			
			if($nav_one['id']>0){
				if($sub_nav_arr[$nav_one['id']]){
					foreach($sub_nav_arr[$nav_one['id']] as $sub_nav){
						
							$sub_nav_str = $sub_nav_str."<li id ='".$sub_nav['id']."'><a href='".$sub_nav['url']."'>".$sub_nav['name']."</a></li>";
						}
					$sub_nav_str= "<ul>".$sub_nav_str."</ul>";
				}
				
			}
			if($nav_one['mod_name'] == MODULE_NAME){ //MODULE_NAME:当前模块儿名称常量
				$nav_choosed = "choose";
			}
			else{
				$nav_choosed = "";
			}

			$nav_str = $nav_str."<li id='".$nav_one['id']."'>
			      <a href='".$nav_one['url']."' class= '".$nav_choosed."'>".$nav_one['name']."</a>
				   ".$sub_nav_str."</li>";		
			
		}

		
		$nav_result = "<ul>".$nav_str."</ul>";

		$this->assign("nav_result",$nav_result);
		$this->assign("current_mod",MODULE_NAME);
		$this->assign("title",C('CMS_NAME'));

	}


}
?>